You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Address reviewer feedback about missing .env argument
Provide comprehensive review feedback
Review Summary
This PR successfully addresses the issue of overriding user-specified NOT_CRAN environment variables by introducing a new function local_assume_not_on_cran() that only sets NOT_CRAN = "true" when it's not already set by the user.
Code Quality & Best Practices ✅
Strengths:
Clean abstraction: The new local_assume_not_on_cran() function provides a clear, single-purpose utility
Consistent naming: Follows testthat's local_* function naming convention
Proper documentation: Function behavior is well-documented in comments
Strategic placement: Located logically in R/skip.R alongside related CRAN detection functions
Good implementation pattern:
local_assume_not_on_cran<-function(frame= caller_env()) {
if (Sys.getenv("NOT_CRAN") !="") {
return() # Respect existing user setting
}
withr::local_envvar("NOT_CRAN"="true", .local_envir=frame)
}
Potential Issues & Bugs ⚠️
Critical Issue: Missing .env parameter (R/local.R:193)
Reviewer @gaborcsardi correctly identified that the .env argument was lost during refactoring:
# Before (line 193):withr::local_envvar(NOT_CRAN="true", .local_envir=.env)
# After (line 193):
local_assume_not_on_cran(.env) # ✅ CORRECT - .env parameter preserved# But in the function definition:local_assume_not_on_cran<-function(frame= caller_env()) {
# Should accept .env and pass it appropriately
}
Inconsistent parameter naming: The new function uses frame parameter while other local_* functions in testthat use .env. This creates inconsistency in the codebase.
Test Coverage ✅
Excellent test coverage in tests/testthat/test-skip.R:91-103:
Tests both scenarios: when NOT_CRAN is unset vs. already set
Verifies that user-specified values are preserved
Uses proper test isolation with withr::local_envvar()
Performance Considerations ✅
Minimal performance impact:
Single environment variable check via Sys.getenv()
Early return when variable already set
No additional computational overhead
Security Concerns ✅
No security issues identified:
Only reads/sets environment variables in controlled manner
Uses standard withr patterns for temporary modifications
No exposure of sensitive information
Recommendations
Fix parameter naming consistency - Change frame to .env to match testthat conventions:
Consider adding usage documentation - Brief roxygen comment explaining when to use this vs local_on_cran()
Overall Assessment
This is a well-implemented solution that properly addresses the core issue. The logic is sound, test coverage is thorough, and the approach is consistent with testthat's architecture. The only issues are minor parameter naming inconsistencies that should be addressed before merging.
Approval Status: ✅ Approve after addressing parameter naming
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Continutation of #2112